<template>
  <aside>
    <el-row :gutter="15">
      <el-col :span="2.5">
        <el-button type="primary" size="mini" icon="el-icon-circle-plus-outline" @click="AddOnline">在线入库</el-button>
        <warehousing-online ref="addComponent" />
      </el-col>
      <el-col :span="2">
        <el-button type="primary" size="mini" icon="el-icon-delete" @click="delFun">删除</el-button>
      </el-col>
      <el-col :span="2">
        <el-button type="primary" size="mini" icon="el-icon-search" @click="handleSearch">查找</el-button>
        <search-btn-page ref="searchBtn" />
      </el-col>
      <el-col :span="2.5">
        <el-button type="primary" size="mini" icon="el-icon-check" @click="confirmIn">确认入库</el-button>
      </el-col>
      <el-col :span="3">
        <el-button type="primary" size="mini" icon="el-icon-download">下载物流码</el-button>
      </el-col>
      <el-col :span="2.5">
        <el-button type="primary" size="mini" icon="el-icon-upload2">上传结果</el-button>
      </el-col>
    </el-row>
  </aside>
</template>

<script>
import warehousingOnline from './warehousing-online'
import searchBtnPage from './search-btn-page'
export default {
  components: {
    warehousingOnline,
    searchBtnPage
  },
  props: {
    selectArr: {
      type: Array,
      default() {
        return []
      }
    }
  },
  methods: {
    delFun() {
      if (!this.selectArr.length) {
        this.$message.info('请先选择要删除的数据！')
      } else {
        let msg = ''
        for (const i in this.selectArr) {
          msg += ' ' + this.selectArr[i].id + ' '
        }
        this.$confirm('是否确认删除单号为' + msg + '的入库记录？', '提示', {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          console.log('删除')
        }).catch(() => {
          console.log('取消')
        })
      }
    },
    confirmIn() {
      if (!this.selectArr.length) {
        this.$message.info('请先选择需要确认的数据！')
      } else {
        let msg = ''
        for (const i in this.selectArr) {
          msg += ' ' + this.selectArr[i].id + ' '
        }
        this.$confirm('是否要将单号为' + msg + '的入库记录确认入库？', '提示', {
          confirmButtonText: '确认',
          cancelButtonText: '取消',
          type: 'success'
        }).then(() => {
          console.log('确认')
        }).catch(() => {
          console.log('取消')
        })
      }
    },
    AddOnline() {
      this.$refs['addComponent'].dialogFormVisible = true
    },
    handleSearch() {
      this.$refs.searchBtn.dialogFormVisible = true
    }
  }

}
</script>

<style lang="scss" scoped>
    .el-button {
        width: 100%;
    }
</style>
